#!/bin/bash
USER=$(whoami)
nvim_file=/tmp/nvim.appimage

pushd /tmp

if [ ! -f ${nvim_file} ]; then
	wget -c https://github.com/neovim/neovim/releases/latest/download/nvim.appimage -O $nvim_file
	chmod u+x ${nvim_file}
	/tmp/nvim.appimage --appimage-extract
	if [ "$USER" == "root" ]; then
		mv squashfs-root /usr/local/nvim
		ln -s /usr/local/nvim/AppRun /usr/bin/vim
		rm -rf /tmp/*
	else
		sudo mv squashfs-root /usr/local/nvim
		sudo ln -s /usr/local/nvim/AppRun /usr/bin/vim
		sudo rm -rf /tmp/*
	fi
fi
popd

NVIM_CONFIG=${HOME}/.config/nvim
if [ ! -d "${NVIM_CONFIG}" ]; then
	git clone -b lite https://github.com/bleedingfight/nvimdots.git "${NVIM_CONFIG}"
fi
